package master.usefulClosures;

import java.awt.event.*;

import javax.swing.*;

import master.ComplexNumber;


public class AnimatedComplexNumber extends ComplexNumber implements ActionListener{
	
	public static Timer t = new Timer(20,null);
	float inc;
	
	public AnimatedComplexNumber(float re, float im, float inc) {
		super(re, im);
		t.addActionListener(this);
		if(!t.isRunning())t.start();
		this.inc = inc;
	}

	
	public void actionPerformed(ActionEvent e) {
		float mag = this.magnitude().getReal();
		float angle = this.phase().getReal()+inc;
		ComplexNumber c = ComplexNumber.expi(mag, angle);
		this.setReal(c.getReal());
		this.setImaginary(c.getImaginary());
	}
	
}
